package com.study.a11Test6;

import com.study.a10Test5.MyRunnable;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Server {
    public static void main(String[] args) throws IOException {


        //创建线程池对象
       /* ThreadPoolExecutor pool=new ThreadPoolExecutor(
                2,//核心线程数
                4,//最大线程数
                60,//线程空闲时间
                TimeUnit.SECONDS,//线程空闲时间单位
                new ArrayBlockingQueue<>(2),//任务队列
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );*/
        ServerSocket ss = new ServerSocket(9000);


        while (true) {
            //监听客户端连接
            Socket socket = ss.accept();

            //开启一条线程
            //一个用户对应一条线程

           /* MyRunnable myRunnable=new MyRunnable(socket);
            Thread thread=new Thread(myRunnable);
            thread.start();*/
            new Thread(new MyRunnable(socket)).start();
        }

    }}
